/** 
 * DefaultSeriesResultParser.java Created by iweerarathna on Aug 31, 2011.
 * 
 * Copyright (c) 2011 Virtusa Corporation. All Rights Reserved.<br><br>. 
 * 
 */
package org.uim.cricket.analyzer.parsers.match.impl;

import org.uim.cricket.analyzer.parsers.match.SeriesResultParsable;
import org.uim.cricket.entities.match.CricketMatch;
import org.uim.cricket.entities.match.SeriesPlayed;
import org.uim.cricket.util.HTMLStringUtils;

/**
 * TODO Class description goes here.
 * @version 
 * @author iweerarathna
 */
public class DefaultSeriesResultParser implements SeriesResultParsable {

    @Override
    public SeriesPlayed parseSeriesResult(String source, CricketMatch match) {
        if (source == null || source.length() == 0) return match.getSeries();
        SeriesPlayed result = match.getSeries();
        
        int pos = source.indexOf("</b>");
        if (pos < 0) return result;
        
        source = source.substring(pos + 4).trim();
        source = HTMLStringUtils.cleanHTMLTags(source);
        result.setResultAfterThisMatch(source);
        
        return result;
    }

}
